<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <title>添加食物 - 食物食材食品基本信息Web系统</title>
  <link rel="stylesheet" href="css/style.css">
  <script>
    if (!sessionStorage.getItem('isLoggedIn')) {
      window.location.href = 'login.html';
    }
  </script>
</head>
<body>
  <div class="bg"></div>
  <div class="bg bg2"></div>
  <div class="bg bg3"></div>
  <header>
    <h1>食物食材食品基本信息Web系统</h1>
    <nav>
      <div class="user-menu" id="userMenu">
        <img src="img/avatar.png" alt="头像" class="avatar" id="userAvatar">
        <span class="username" id="usernameDisplay">用户</span>
        <span class="dropdown-arrow">&#9662;</span>
        <div class="dropdown-menu" id="dropdownMenu">
          <a href="#" id="profileLink"><span class="menu-icon">&#8962;</span> 个人空间</a>
          <a href="login.html" id="logout"><span class="menu-icon">&#9906;</span> 退出登录</a>
        </div>
      </div>
    </nav>
  </header>
  <main>
    <a href="index.html" class="back-home-btn"><span>返回首页</span></a>
    <section>
      <h2>添加食物基本信息</h2>
      <form id="addFoodForm" class="data-form" enctype="multipart/form-data">
        <div class="form-row">
          <div class="form-group">
            <label for="foodName"><span style="color:red">*</span>食物名称：</label>
            <input type="text" id="foodName" name="foodName" required>
          </div>
          <div class="form-group">
            <label for="origin"><span style="color:red">*</span>产地：</label>
            <input type="text" id="origin" name="origin" required>
          </div>
        </div>
        <div class="form-row">
          <div class="form-group">
            <label for="productionDate"><span style="color:red">*</span>出产日期：</label>
            <input type="date" id="productionDate" name="productionDate" required>
          </div>
          <div class="form-group">
            <label for="producer"><span style="color:red">*</span>生产单位/农户：</label>
            <input type="text" id="producer" name="producer" required>
          </div>
        </div>
        <div class="form-row">
          <div class="form-group">
            <label for="season"><span style="color:red">*</span>出产季节：</label>
            <select id="season" name="season" required>
              <option value="">请选择季节</option>
              <option value="春季">春季</option>
              <option value="夏季">夏季</option>
              <option value="秋季">秋季</option>
              <option value="冬季">冬季</option>
              <option value="全年">全年</option>
            </select>
          </div>
          <div class="form-group">
            <label for="description">描述：</label>
            <textarea id="description" name="description" rows="3" placeholder="可选：添加食物描述信息"></textarea>
          </div>
        </div>
        <div class="form-group">
          <label for="photo"><span style="color:red">*</span>照片：</label>
          <input type="file" id="photo" name="photo" accept="image/*" required>
        </div>
        <div class="form-actions">
          <button type="submit" class="btn btn-primary">保存食物信息</button>
          <button type="button" class="btn btn-secondary" id="resetBtn">重置表单</button>
        </div>
      </form>
    </section>
    
    <section id="successMessage" style="display: none;">
      <div class="success-alert">
        <h3>添加成功！</h3>
        <p>食物信息已成功保存到数据库。</p>
        <button class="btn btn-primary" onclick="location.reload()">继续添加</button>
        <a href="search.html" class="btn btn-secondary">查看数据</a>
      </div>
    </section>
  </main>
  <footer>
    <p>&copy; 2025 食物食材食品基本信息Web系统</p>
  </footer>
  <script src="js/add_food.js"></script>
  <script src="js/user_menu.js"></script>
</body>
</html> 